# -*- coding: UTF-8 -*-
import os
import json
from tools.handle_path import config_path


def get_param():
    file_path = os.path.join(config_path, 'initialization.json')
    with open(file_path, 'r', encoding='utf8') as f:
        json_data = json.load(f)
    # 平台地址
    deepfos_host = json_data.get("deepfos_host")
    # 账户中心地址
    account_host = json_data.get("account_host")
    username = json_data.get("user").get("username")
    password = json_data.get("user").get("password")
    # 系统数据库名
    sys_db_name = json_data.get("db_name").get("system")
    # app数据库名
    app_db_name = json_data.get("db_name").get("app")
    # 账户中心数据库名
    account_db_name = json_data.get("db_name").get("account")
    # 数据流数据库名
    pipeline_db_name = json_data.get("db_name").get("pipeline")
    # 计算流数据库名
    calculation_db_name = json_data.get("db_name").get("calculation")
    # 系统数据库连接信息
    database_info = json_data.get("database")
    if json_data.get("account_db"):
        account_db_info = json_data.get("account_db")
    else:
        account_db_info = database_info
    # 是否自动创建空间和app
    auto_create = json_data.get("auto_create")
    space_id = json_data.get("space_id")
    app_id = json_data.get("app_id")
    return deepfos_host, account_host, username, password, sys_db_name, app_db_name, account_db_name, pipeline_db_name, calculation_db_name, database_info, account_db_info, auto_create, space_id, app_id


DEEPFOS_HOST, ACCOUNT_HOST, USER_USER, USER_PWD, SYS_DB_NAME, APP_DB_NAME, ACCOUNT_DB_NAME, PIPELINE_DB_NAME, CALCULATION_DB_NAME, DATABASE_INFO, ACCOUNT_DB_INFO, \
AUTO_CREATE, SPACEID, APPID = get_param()

if __name__ == '__main__':
    print(DEEPFOS_HOST, ACCOUNT_HOST, USER_USER, USER_PWD, SYS_DB_NAME, APP_DB_NAME, ACCOUNT_DB_NAME, PIPELINE_DB_NAME,
          CALCULATION_DB_NAME, DATABASE_INFO, ACCOUNT_DB_INFO, AUTO_CREATE, SPACEID, APPID)
